package com.open.capacity.tenant.model.convert;

import cn.hutool.extra.spring.SpringUtil;
import com.open.capacity.tenant.dao.entity.Tenant;
import com.open.capacity.tenant.model.CreateTenantDto;
import jdk.internal.instrumentation.InstrumentationMethod;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * CreateTenantDto 、 Tenant 转换 -- mapstruct
 * @program: open-capacity-platform
 * @author: GuoGaoJu
 * @create: 2023-03-20
 **/
@Mapper(componentModel = "spring") //将当前bean交由spring IOC容器托管
public interface TenantConvert {

    @Mappings({@Mapping(source = "tenantId",target = "tenant_id")})
    Tenant dto2Po(CreateTenantDto createTenantDto);

    /**
     * 反转，并自动使用反转方法的配置
     * @param tenant
     * @return
     */
    @InheritInverseConfiguration(name = "dto2Po")
    CreateTenantDto po2Dto(Tenant tenant);
}
